bool Push(ElementType X, Deque D)
{
    if((D->Front - D->Rear + D->MaxSize) % D->MaxSize == 1) //full
    {
        return false;
    }
    D->Front = (D->Front - 1 + D->MaxSize) % D->MaxSize;
    D->Data[D->Front] = X;
    
    return true;
}

ElementType Pop(Deque D)
{
    if(D->Front == D->Rear) //empty
    {
        return ERROR;
    }
    int data = D->Data[D->Front];
    D->Front = (D->Front + 1) % D->MaxSize;
    
    return data;
}

bool Inject(ElementType X, Deque D)
{
    if((D->Front - D->Rear + D->MaxSize) % D->MaxSize == 1) //full
    {
        return false;
    }
    D->Data[D->Rear] = X;
    D->Rear = (D->Rear + 1) % D->MaxSize;
    
    return true;
}

}